package com.shiroha.common.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum Gender {
    MALE("M", "男"),
    FEMALE("F", "女"),
    OTHER("O", "其他");

    @EnumValue
    @JsonValue
    private final String value;
    private final String description;

    Gender(String value, String description) {
        this.value = value;
        this.description = description;
    }

    public static Gender fromValue(String value) {
        for (Gender gender : Gender.values()) {
            if (gender.value.equals(value)) {
                return gender;
            }
        }
        throw new IllegalArgumentException("No gender found for value: " + value);
    }
}
